//@author A0101119Y
#ifndef DBMGR_H
#define DBMGR_H

#include <vector>
#include <ctime>
#include "CommonObjects.h"
#include "FileReader.h"
#include "FileWriter.h"

namespace Twentyfifth {
	class DbMgr {
	private:
		std::string FILENAME_TASKS;
		std::vector<Task> tasks;
		int incrementalCounter;
		DateTime swapDtFields(DateTime oldDt, DateTime newDt, TaskParams);
		int getLargestTaskId();
		int findTaskIdInVector(int id);
	public:
		DbMgr();
		DbMgr(std::string);
		bool isInDatabase(int id);
		void writeAllToFile();
		std::vector<Task>& retrieveAllTasks();
		Status addTask(Task);
		Status editTask(int id, TaskParams param, DateTime newValue);
		Status editTask(int id, TaskParams param, std::string newValue);
		Status editTask(int id, TaskParams param, bool newValue);
		Status viewTask(int id);
		Status viewTasks();
		Status deleteTask(int id, bool isPermanent = false);
		Status undeleteTask(int id);
		Status clearTasks();
		Status searchTasks(std::string searchString);
		Status searchTasks(DateTime searchDate);
	};
}

#endif
